home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Tele / C / Comet2.1.3 Folder / 3270XCMD / TNSendStr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-23  |  1.7 KB  |  91 lines  |  [TEXT/MPS ]

  1. /* TNConnect.c -- XCMD to open the TN3270 driver 
  2.     copyright 1989 Cornell University 
  3.     
  4.     TNConnect hostid:  Connect to a host.
  5.  
  6. */
  7.  
  8.  
  9. #include <Types.h>
  10. #include <Memory.h>
  11. #include <Devices.h>
  12. #include <HyperXCmd.h>
  13. #include <Errors.h>
  14.  
  15. #include <String.h>
  16.  
  17. #include "TNdrvr.h"
  18.  
  19.  
  20. pascal void debugger()    extern 0xA9FF;   
  21.  
  22.  
  23. pascal void TNSendStr(hycp)
  24. XCmdPtr hycp;
  25. {
  26.     CntrlParam drvpb;
  27.     long * args;
  28.     Str255 pstr;
  29.     
  30.     if (hycp->paramCount != 2) {
  31.         sethand(&hycp->returnValue, "TNSendStr TNID,string: need 2 arguments");
  32.         return;
  33.     }
  34.     
  35.     HLock((Handle) hycp->params[0]);
  36.     HLock((Handle) hycp->params[1]);
  37.     
  38.     ZeroToPas(hycp, *hycp->params[0], (StringPtr) &pstr[0]);
  39.     drvpb.ioCRefNum = (short) StrToNum(hycp, (Str31 *) &pstr[0]);
  40.     drvpb.csCode = HTN_SENDSTR;
  41.     args = (long *) &drvpb.csParam[0];
  42.     *args = * (long *) hycp->params[1];
  43.         /* pass the string * to the drvr to pass on to TN3270 */
  44.     PBControl((ParmBlkPtr) &drvpb, (Boolean) 0);
  45.  
  46.     if (drvpb.ioResult) {
  47.         /* connect call failed */
  48.         switch (drvpb.ioResult) {
  49.             case HTNR_NOTN: {
  50.                 sethand(&hycp->returnValue, "TN is not running");
  51.                 break;
  52.             }
  53.             case HTNR_ACTIVE: {
  54.                 sethand(&hycp->returnValue, "TN not opened");
  55.                 break;
  56.             }
  57.             case HTNR_OPEN: {
  58.                 sethand(&hycp->returnValue, "TN has no connection");
  59.                 break;
  60.             }
  61.             case badUnitErr: {
  62.                 sethand(&hycp->returnValue, "TNID is incorrect");
  63.                 break;
  64.             }
  65.             default: {
  66.                 sethand(&hycp->returnValue, "Unknown error");
  67.                 break;
  68.             }
  69.         }
  70.     }
  71.     HUnlock((Handle) hycp->params[0]);
  72.     HUnlock((Handle) hycp->params[1]);
  73.  
  74. }
  75.  
  76.  
  77. sethand(thand, str)
  78. Handle * thand;
  79. char * str;
  80. {
  81.     if (*thand == NULL) {
  82.         *thand = NewHandle((Size) 0);
  83.     }
  84.     SetHandleSize(*thand, (long) (strlen(str) + 1));
  85.     strcpy(**thand, str);
  86. }
  87.  
  88.  
  89.  
  90.  
  91. #include <XCmdGlue.inc.c>